﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CIIS.Common
{
    public partial class NormalSignature : UserControl
    {
        public NormalSignature()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 本方法要删除
        /// </summary>
        /// <param name="detailCaption"></param>
        /// <param name="signatureCaption"></param>
        /// <param name="dateCaption"></param>
        public void InitControl(string detailCaption, string signatureCaption, string dateCaption)
        {
            layoutControlItemDetail.Text = detailCaption;
            layoutControlItemSignature.Text = signatureCaption;
            layoutControlItemDate.Text = dateCaption;
        }

        public void InitControl(string detailCaption, string signatureCaption, string dateCaption, DropdownControlParam dcp)
        {
            layoutControlItemDetail.Text = detailCaption;
            layoutControlItemSignature.Text = signatureCaption;
            layoutControlItemDate.Text = dateCaption;

            dateEditQzsj.DateTime = DateTime.Today;
            DevControlUtils.Instance.InitSearchLookUpEdit(searchLookUpEditQm, dcp);
        }

        public void SetValues(object[] values)
        {
            if (values == null || values.Length != 3)
            {
                return;
            }

            if (values[0] != null)
            {
                memoEditYj.Text = values[0].ToString();
            }
            searchLookUpEditQm.EditValue = values[1];
            DateTime? sj = values[2] as DateTime?;
            if (sj.HasValue)
            {
                dateEditQzsj.DateTime = sj.Value;
            }
        }

        public void BindData(object obj, string[] values)
        {
            if (obj == null || values == null || values.Length != 3)
            {
                return;
            }

            memoEditYj.DataBindings.Add("Text", obj, values[0]);
            searchLookUpEditQm.DataBindings.Add("EditValue", obj, values[1]);
            //dateEditQzsj.DataBindings.Add("DateTime", obj, values[2]);
        }

        public DateTime Qzsj
        {
            get { return dateEditQzsj.DateTime; }
        }

        public string Yj
        {
            get { return memoEditYj.Text; }
        }

        public string Qz
        {
            get { return searchLookUpEditQm.EditValue != null ? searchLookUpEditQm.EditValue.ToString() : string.Empty; }
        }
    }
}
